<template lang="html">
  <div class="header">
    <div class="content-wrapper">
      <div class="left-wrapper">
        <img :src="seller.avatar" width="64" height="64" alt="">
      </div>
      <div class="right-wrapper">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="descript">
          {{seller.description}}/{{seller.deliveryTime}}分钟送达
        </div>
        <div v-if="seller.supports" class="support">
          <span class="icon" :class="classMap[seller.supports[0].type]"></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div v-if="seller.supports" class="support-count" @click="showDetail">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div class="bulletin-wrapper" @click="showDetail">
      <span class="bulletin-brand"></span><span class="bulletin-desc">{{seller.bulletin}}</span>
      <i class="icon-keyboard_arrow_right"></i>
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%" alt="">
    </div>
    <transition name="fade">
      <div v-show="show" class="detail">
        <div class="detail-wrapper">
          <div class="detail-main">
            <h1 class="name">{{seller.name}}</h1>
            <div class="star-wrapper">
              <star :size="48" :score="seller.score"></star>
            </div>
            <header-title :name="offer"></header-title>
            <ul v-if="seller.supports" class="supports">
              <li class="item" v-for="support in seller.supports" :key="support.index">
                <span class="icon" :class="classMap[support.type]"></span>
                <span class="text">{{support.description}}</span>
              </li>
            </ul>
            <header-title :name="shop"></header-title>
            <div class="bulletin">
              <p class="content">{{seller.bulletin}}</p>
            </div>
          </div>
        </div>
        <div class="detail-colse">
          <i class="icon-close" @click="closeDetail"></i>
        </div>
      </div>
    </transition>
  </div>
</template>

<script type="text/ecmascript0-6">
import star from '@/components/star/star.vue';
import headerTitle from '@/components/headerTitle/headerTitle.vue';

export default {
  name: 'header',
  props: {
    seller: {
      type: Object
    }
  },
  data() {
    return {
      offer: '优惠信息',
      shop: '商家公告',
      show: false
    };
  },
  components: {
    star,
    'header-title': headerTitle
  },
  created() {
    this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee'];
  },
  methods: {
    showDetail() {
      this.show = true;
    },
    closeDetail() {
      this.show = false;
    }
  }
};
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import '../../common/stylus/mixin.styl';

  .header
    position: relative
    overflow: hidden
    background: rgba(7, 17, 27, .5)
    .content-wrapper
      display: flex
      position: relative
      padding: 24px 0 18px 24px
      font-size: 0
      .left-wrapper
        flex: 0 0 64px
        width: 64px
        display: inline-block
        vertical-align: top
        img
          border-radius: 2px
      .right-wrapper
        flex: 1
        margin-left: 16px
        color: rgb(255, 255, 255)
        .title
          padding: 2px 0 8px 0
          font-size: 0
          .brand
            display: inline-block
            vertical-align: top
            width: 30px
            height: 18px
            icon-img('brand')
            background-size: 30px 18px
            background-repeat: no-repeat
          .name
            display: inline-block
            margin-left: 6px
            line-height: 18px
            font-size: 18px
            font-weight: bold
        .descript
          margin-bottom: 10px
          line-height: 12px
          font-size: 12px
        .support
          font-size: 0
          .icon
            display: inline-block
            vertical-align: top
            width: 12px
            height: 12px
            margin-bottom: 2px
            background-size: 12px 12px
            background-repeat: no-repeat
            &.decrease
              icon-img('decrease_1')
            &.discount
              icon-img('discount_1')
            &.special
              icon-img('special_1')
            &.invoice
              icon-img('invoice_1')
            &.guarantee
              icon-img('guarantee_1')
          .text
            margin-left: 4px
            line-height: 12px
            font-size: 10px
      .support-count
        position: absolute
        right: 12px
        bottom: 14px
        padding: 0 8px
        height: 24px
        border-radius: 24px
        color: rgb(255, 255, 255)
        background-color: rgba(0, 0, 0, .2)
        .count
          line-height: 24px
          font-size: 10px
        .icon-keyboard_arrow_right
          margin-left: 2px
          line-height: 24px
          font-size: 10px
    .bulletin-wrapper
      position: relative
      height: 28px
      line-height: 28px
      padding: 0 22px 0 12px
      white-space: nowrap
      overflow: hidden
      text-overflow: ellipsis
      color: rgb(255, 255, 255)
      background: rgba(7, 17, 27, .2)
      .bulletin-brand
        display: inline-block
        vertical-align: top
        width: 22px
        height: 12px
        margin-top: 8px
        icon-img('bulletin')
        background-size: 22px 12px
        background-repeat: no-repeat
      .bulletin-desc
        vertical-align: top
        margin: 0 4px
        font-size: 10px
      .icon-keyboard_arrow_right
        position: absolute
        top: 8px
        right: 12px
        font-size: 10px
    .background
      position: absolute
      top: 0
      left: 0
      width: 100%
      height: 100%
      z-index: -1
      filter: blur(10px)
    .detail
      position: fixed
      top: 0
      left: 0
      width: 100%
      height: 100%
      overflow: auto
      z-index: 100
      background: rgba(7, 17, 27, .8)
      backdrop-filter: blur(10px)
      transition: all .5s
      &.fade-enter-active, &fade-leave-active
        opacity: 1
      &.fade-enter, &.fade-leave-active
        opacity: 0
      .detail-wrapper
        width: 100%
        min-height: 100%
        .detail-main
          padding-top: 64px
          padding-bottom: 64px
          .name
            line-height: 16px
            text-align: center
            font-size: 16px
            font-weight: 700
            color: #fff
          .star-wrapper
            margin-top: 16px
            text-align: center
          .supports
            width: 80%
            margin: 0 auto
            padding: 0 12px
            box-sizing: border-box
            font-size: 0
            .item
              margin-bottom: 12px
              &:last-child
                margin-bottom: 0
              .icon
                display: inline-block
                width: 16px
                height: 16px
                vertical-align: top
                margin-right: 6px
                background-size: 16px 16px
                background-repeat: no-repeat
                &.decrease
                  icon-img('decrease_2')
                &.discount
                  icon-img('discount_2')
                &.special
                  icon-img('special_2')
                &.invoice
                  icon-img('invoice_2')
                &.guarantee
                  icon-img('guarantee_2')
              .text
                line-height: 16px
                font-size: 12px
                color: #fff
          .bulletin
            width: 80%
            margin: 0 auto
            padding: 0 12px
            box-sizing: border-box
            .content
              line-height: 24px
              font-size: 12px
              color: #fff
      .detail-colse
        position: relative
        width: 32px
        height: 32px
        margin: -64px auto 0 auto
        clear: both
        font-size: 32px
        color: rgba(255, 255, 255, .5)
</style>
